<template>
    <div>
      <h3>这是会员展示页</h3>
      <table border="1">
        <tr>
          <th>会员名称</th>
          <th>会员级别</th>
          <th>会员操作</th>
        </tr>
        <tr v-for="item in list">
          <td>{{ item.username }}</td>
          <td v-if="item.huiyuan == 0">普通会员</td>
          <td v-else>VIP</td>
          <td v-if="item.huiyuan == 1">以是最高级别会员</td>
          <td v-else>
            <button type="submit" @click="submit(item.id)">升级为VIP</button>
          </td>
        </tr>

      </table>

    </div>
</template>

<script>
    export default {
        data(){
            return{
                list:[]
            }
        },
        mounted() {
            this.axios.get('http://127.0.0.1:8000/userlist').then(res=>{
                if (res.data.code == 200){
                    this.list = res.data.data
                }
            })
        },
        methods:{
            submit(id){
                this.axios.get('http://127.0.0.1:8000/vip',{params:{
                        'id':id
                    }}).then(res=>{
                        if (res.data.code == 200){
                            alert(res.data.data)
                        }
                })
            }
        }
    }
</script>

<style scoped>

</style>
